home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SOURCE.BIN / LogonFrame.java < prev    next >
Encoding:
Java Source  |  1997-06-19  |  4.3 KB  |  164 lines

  1. /*
  2.  *
  3.  * 2     3/20/97 10:51a Tjones
  4.  * Modified UI so that it's no longer 'ugly as sin'.
  5.  *
  6.  * 1     11/01/96 1:43p Cthrons
  7.  * Replacement for SCLLoginFrame.
  8.  *
  9. */
  10.  
  11. package symantec.itools.db.awt;
  12.  
  13. import java.awt.Button;
  14. import java.awt.Label;
  15. import java.awt.Font;
  16. import java.awt.Event;
  17. import java.util.*;
  18. import symjava.sql.*;
  19. import java.lang.*;
  20. import java.awt.*;
  21. import symantec.itools.db.net.*;
  22. import symantec.itools.db.pro.*;
  23.  
  24. public class LogonFrame extends java.awt.Frame implements Logon
  25. {
  26.     //{{DECLARE_CONTROLS
  27.     symantec.itools.awt.KeyPressManagerPanel keyPressManagerPanel1;
  28.     java.awt.Button OK;
  29.     java.awt.Button Cancel;
  30.     java.awt.TextField UserNameEdit;
  31.     java.awt.TextField UserPasswordEdit;
  32.     java.awt.Label label3;
  33.     java.awt.Label label4;
  34.     java.awt.Label datasource;
  35.     java.awt.Label datasource1;
  36.     //}}
  37.  
  38.     ConnectionInfo  m_ConnectionInfo;
  39.     boolean         m_Action;
  40.  
  41.     // Thread inputThread;
  42.  
  43.     public LogonFrame() {
  44.  
  45.         super("LogonFrame window");
  46.  
  47.         //{{INIT_CONTROLS
  48.         setLayout(null);
  49.         addNotify();
  50.         resize(insets().left + insets().right + 360,insets().top + insets().bottom + 152);
  51.         setBackground(new Color(12632256));
  52.         keyPressManagerPanel1 = new symantec.itools.awt.KeyPressManagerPanel();
  53.         keyPressManagerPanel1.setLayout(null);
  54.         keyPressManagerPanel1.reshape(insets().left + 0,insets().top + 0,360,152);
  55.         add(keyPressManagerPanel1);
  56.         OK = new java.awt.Button("OK");
  57.         OK.reshape(68,108,85,25);
  58.         keyPressManagerPanel1.add(OK);
  59.         Cancel = new java.awt.Button("Cancel");
  60.         Cancel.reshape(164,108,85,25);
  61.         keyPressManagerPanel1.add(Cancel);
  62.         UserNameEdit = new java.awt.TextField(28);
  63.         UserNameEdit.reshape(164,37,166,23);
  64.         keyPressManagerPanel1.add(UserNameEdit);
  65.         UserPasswordEdit = new java.awt.TextField(28);
  66.         UserPasswordEdit.setEchoCharacter('*');
  67.         UserPasswordEdit.reshape(164,65,166,23);
  68.         keyPressManagerPanel1.add(UserPasswordEdit);
  69.         label3 = new java.awt.Label("User Name:");
  70.         label3.reshape(56,40,90,15);
  71.         keyPressManagerPanel1.add(label3);
  72.         label4 = new java.awt.Label("Password:");
  73.         label4.reshape(64,68,90,15);
  74.         keyPressManagerPanel1.add(label4);
  75.         datasource = new java.awt.Label("DataSource Name:");
  76.         datasource.reshape(16,5,133,15);
  77.         keyPressManagerPanel1.add(datasource);
  78.         datasource1 = new java.awt.Label("DataSource Name:");
  79.         datasource1.reshape(164,5,200,15);
  80.         keyPressManagerPanel1.add(datasource1);
  81.         setTitle("Untitled");
  82.         //}}
  83.  
  84.         //{{INIT_MENUS
  85.         //}}
  86.  
  87.  
  88.     }
  89.  
  90.     public void show()
  91.     {
  92.         super.show();
  93.     }
  94.  
  95.     public boolean handleEvent(Event event) {
  96.         if (event.id == Event.ACTION_EVENT && event.target == Cancel) {
  97.                 clickedCancel();
  98.                 return true;
  99.         }
  100.         else if (event.id == Event.ACTION_EVENT && event.target == OK) {
  101.                 clickedOK();
  102.                 return true;
  103.         }
  104.         else if (event.id == Event.WINDOW_DESTROY) {
  105.             hide();
  106.             return true;
  107.         }
  108. /*        else if (event.id == Event.KEY_PRESS) {
  109.             if (event.key == 9) // tab
  110.             {
  111.                 if (event.target == UserNameEdit)
  112.                 {
  113.                     UserPasswordEdit.requestFocus();
  114.                 }
  115.                 else
  116.                 {
  117.                     UserNameEdit.requestFocus();
  118.                 }
  119.             }
  120.         }*/
  121.         return super.handleEvent(event);
  122.     }
  123.  
  124.     //{{DECLARE_MENUS
  125.     //}}
  126.  
  127.     public void clickedOK() {
  128.         m_ConnectionInfo.setUser(UserNameEdit.getText());
  129.         m_ConnectionInfo.setPassword(UserPasswordEdit.getText());
  130.         m_Action = true;
  131.         hide();
  132.     }
  133.  
  134.     public void clickedCancel() {
  135.         m_Action = false;
  136.         hide();
  137.     }
  138.  
  139.     public boolean logonFailed(ConnectionInfo conn, int retries)
  140.     {
  141.         m_ConnectionInfo = conn;
  142.  
  143.         // Fill controls with properties sent in
  144.         UserNameEdit.setText(conn.getUser());
  145.         UserPasswordEdit.setText(conn.getPassword());
  146.         datasource1.setText(conn.getDBString());
  147.  
  148.         setTitle("User Authentication");
  149.  
  150.         // Allow user input
  151.         show();
  152.  
  153.         while (isVisible())
  154.         {
  155.             Thread.currentThread().yield();           // Give up cpu
  156.         }
  157.  
  158.         conn = m_ConnectionInfo;
  159.  
  160.         // Pass the input back to the caller
  161.         return m_Action;
  162.     }
  163. }
  164.